/*
 * Authors:  Alex Kaufmann & Aaron Dalman
 * Course:  CST 438
 * Title: Crappy Craps
 * Date:  February 9, 2012
 *
 */


import java.util.Random;
import java.util.Scanner;

public class craps {

    public static void main(String[] args) {
       
        boolean first = true; //First roll
        int die1;
        int die2;
        int total;
        int point = 0;
        Random generator = new Random();
        String rollAgain = "y";
       
        Scanner input = new Scanner(System.in);
           
        do{   
           
           
        if(first){ //Check if first roll
            System.out.println("\n======== NEW GAME =========");

            die1 = generator.nextInt(6) + 1;
            die2 = generator.nextInt(6) + 1;
            total = die1 + die2;
            System.out.println("Die One: " + die1 + "\nDie Two: " + die2 + "\nYour total roll is " + total);
            if(total == 7 || total == 11){
                System.out.println("You Win");
            }
           
            else if(total == 2 || total == 3 || total ==12){
                System.out.println("You lose");
            }
           
            else {
                point = total;
                System.out.println("Point is " + point);
                first = false;
            }
           
        }else{ //If not first roll
            die1 = generator.nextInt(6) + 1;
            die2 = generator.nextInt(6) + 1;
            total = die1 + die2;
            System.out.println("Die One: " + die1 + "\nDie Two: " + die2 + "\nYour total roll is " + total);
            if(total == point){
                System.out.println("Point matched.  You win.");
                first = true;
            }else if(total == 7){
                System.out.println("You Lose");
                first = true;
            }else{
                System.out.println("Point not matched. Point is " + point);
            }
        }
       
        System.out.println("Roll again?");
        rollAgain = input.next();
       
        }while(rollAgain.equals("y") || rollAgain.equals("Y"));

    }

}